wayland: Reference pixmap-based cursors' surface before handing the wl_buffer
authorCarlos Garnacho <carlosg@gnome.org>
Mon, 1 Sep 2014 16:44:48 +0000 (18:44 +0200)
committerCarlos Garnacho <carlosg@gnome.org>
Mon, 1 Sep 2014 18:46:29 +0000 (20:46 +0200)
cairo_surface_destroy() is called after the buffer is released, for every
wl_buffer. Windows usually reference their cairo surface before rendering,
so that extra reference is consumed after the buffer is released, so do
the same with cursor surfaces and add an extra reference whenever a cursor
surface change is about to be scheduled.

Otherwise, the GdkWaylandCursor is left with an invalid cairo_surface_t,
which causes crashes the next time it is used.

https://bugzilla.gnome.org/show_bug.cgi?id=735830

gdk/wayland/gdkcursor-wayland.c

index 6702ce71ca466076f2c49582d2074aee2840289d..b247fad6b3f1dce5f595a9a824d5aba00304f8f9 100644 (file)
@@ -179,6 +179,8 @@ _gdk_wayland_cursor_get_buffer (GdkCursor *cursor,
       *h = wayland_cursor->surface.height / wayland_cursor->surface.scale;
       *scale = wayland_cursor->surface.scale;
 
+      cairo_surface_reference (wayland_cursor->surface.cairo_surface);
+
       if (wayland_cursor->surface.cairo_surface)
         return _gdk_wayland_shm_surface_get_wl_buffer (wayland_cursor->surface.cairo_surface);
       else